﻿/*
 * 作者：李博
 * 功能：从井身结构、剖面压力以及API数据中导入数据，作为套管柱设计的基础
 * 时间：2018-1-19
 * 修改人：
 * 修改时间：
 */

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataAccess;

namespace DataBusiness
{
    public class CasDesignDataInputBLL
    {
        public static DataTable getAPISet()
        {
            string sSql = "select * from tb_API";
            DataTable initDT = SqlHelper.QuerySql(sSql).Tables[0];
            initDT.Columns[0].ColumnName = "ID";
            initDT.Columns[1].ColumnName = "外径";
            initDT.Columns[2].ColumnName = "钢级";
            initDT.Columns[3].ColumnName = "线重";
            initDT.Columns[4].ColumnName = "扣型";
            initDT.Columns[5].ColumnName = "壁厚";
            initDT.Columns[6].ColumnName = "内径";
            initDT.Columns[7].ColumnName = "通径";
            initDT.Columns[8].ColumnName = "抗外挤强度";
            initDT.Columns[9].ColumnName = "抗内压强度";
            initDT.Columns[10].ColumnName = "接箍抗拉强度";
            initDT.Columns[11].ColumnName = "管体屈服强度";

            DataTable retDt = new DataTable();
            retDt.Columns.Add(new DataColumn(("外径"),typeof(string)));
            retDt.Columns.Add(new DataColumn(("钢级"), typeof(string)));
            retDt.Columns.Add(new DataColumn(("线重"), typeof(string)));
            retDt.Columns.Add(new DataColumn(("扣型"), typeof(string)));
            retDt.Columns.Add(new DataColumn(("壁厚"), typeof(string)));
            retDt.Columns.Add(new DataColumn(("抗外挤强度"), typeof(string)));
            retDt.Columns.Add(new DataColumn(("抗内压强度"), typeof(string)));
            retDt.Columns.Add(new DataColumn(("接箍抗拉强度"), typeof(string)));
            retDt.Columns.Add(new DataColumn(("管体屈服强度"), typeof(string)));

            DataRow dr;
            foreach(DataRow row in initDT.Rows)
            {
                dr = retDt.NewRow();
                dr["外径"] = row["外径"];
                dr["钢级"] = row["钢级"];
                dr["线重"] = row["线重"];
                dr["扣型"] = row["扣型"];
                dr["壁厚"] = row["壁厚"];
                dr["抗外挤强度"] = row["抗外挤强度"];
                dr["抗内压强度"] = row["抗内压强度"];
                dr["接箍抗拉强度"] = row["接箍抗拉强度"];
                dr["管体屈服强度"] = row["管体屈服强度"];
                retDt.Rows.Add(dr);
            }
            return retDt;
        }

        public static DataTable getAPISet(float OutsiderDiameter)
        {
            string sSql = string.Format("select * from tb_API where OutsideDiameter = '{0}'", OutsiderDiameter);
            DataSet ds = SqlHelper.QuerySql(sSql);
            return ds.Tables[0];
        }
    }
}
